﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Windows.Forms;

    public class clsChiTietDieuKhoanChungTu
    {
        private int mHienThi = 0;
        private string mKhoa = "";
        private string mKhoaChungTu = "";
        private string mKhoaDieuKhoan = "";
        private string mLoaiChungTu = "";
        private string mNoiDungAnh = "";
        private string mNoiDungViet = "";
        private int mSTT = 0;

        public bool DeleteBaoGiaTemp(string pKhoa)
        {
            bool flag=false;
            try
            {
                string commandText = "DELETE FROM BH_DieuKhoanBaoGiaTemplate WHERE Khoa = '" + pKhoa.Trim() + "'";
                DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public DataTable GetDieuKhoanTemplate(string strLoai)
        {
            string commandText = "SELECT T.Khoa, T.KhoaDieuKhoan, DK.Ten" + modGeneral.H_LANGUAGE + " as DieuKhoan, T.NoiDungViet, T.NoiDungAnh, T.HienThi  FROM BH_DieuKhoanBaoGiaTemplate T left join DM_DieuKhoanBaoGia DK on T.KhoaDieuKhoan = DK.Khoa  WHERE T.LoaiChungTu = '" + strLoai + "' ORDER BY STT ";
            return DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
        }

        public bool SaveBaoGiaDieuKhoan()
        {
            bool flag2;
            IDataParameter[] commandParameters = new IDataParameter[7];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaBaoGia", DbType.Int64, ParameterDirection.Input, this.mKhoaChungTu);
                commandParameters[2] = DBHelper.createParameter("@KhoaDieuKhoan", DbType.Int64, ParameterDirection.Input, this.mKhoaDieuKhoan);
                commandParameters[3] = DBHelper.createParameter("@NoiDungViet", DbType.Int64, ParameterDirection.Input, this.mNoiDungViet);
                commandParameters[4] = DBHelper.createParameter("@NoiDungAnh", DbType.Int64, ParameterDirection.Input, this.mNoiDungAnh);
                commandParameters[5] = DBHelper.createParameter("@HienThi", DbType.Double, ParameterDirection.Input, this.mHienThi);
                commandParameters[6] = DBHelper.createParameter("@STT", DbType.Double, ParameterDirection.Input, this.mSTT);
                bool flag = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "BH_sp_BaoGiaChiTietDieuKhoan", commandParameters) > 0;
                flag2 = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag2 = false;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public bool SaveDieuKhoanTemp()
        {
            bool flag2;
            IDataParameter[] commandParameters = new IDataParameter[7];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaDieuKhoan", DbType.Int64, ParameterDirection.Input, this.mKhoaDieuKhoan);
                commandParameters[2] = DBHelper.createParameter("@NoiDungViet", DbType.Int64, ParameterDirection.Input, this.mNoiDungViet);
                commandParameters[3] = DBHelper.createParameter("@NoiDungAnh", DbType.Int64, ParameterDirection.Input, this.mNoiDungAnh);
                commandParameters[4] = DBHelper.createParameter("@LoaiChungTu", DbType.Int64, ParameterDirection.Input, this.mLoaiChungTu);
                commandParameters[5] = DBHelper.createParameter("@HienThi", DbType.Double, ParameterDirection.Input, this.mHienThi);
                commandParameters[6] = DBHelper.createParameter("@STT", DbType.Double, ParameterDirection.Input, this.mSTT);
                bool flag = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "BH_sp_DieuKhoanBaoGiaTemplate", commandParameters) > 0;
                flag2 = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag2 = false;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public bool SaveDonDatHangDieuKhoan()
        {
            bool flag2;
            IDataParameter[] commandParameters = new IDataParameter[6];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaDonDatHang", DbType.Int64, ParameterDirection.Input, this.mKhoaChungTu);
                commandParameters[2] = DBHelper.createParameter("@KhoaDieuKhoan", DbType.Int64, ParameterDirection.Input, this.mKhoaDieuKhoan);
                commandParameters[3] = DBHelper.createParameter("@NoiDungViet", DbType.Int64, ParameterDirection.Input, this.mNoiDungViet);
                commandParameters[4] = DBHelper.createParameter("@NoiDungAnh", DbType.Int64, ParameterDirection.Input, this.mNoiDungAnh);
                commandParameters[5] = DBHelper.createParameter("@HienThi", DbType.Double, ParameterDirection.Input, this.mHienThi);
                commandParameters[6] = DBHelper.createParameter("@STT", DbType.Double, ParameterDirection.Input, this.mSTT);
                bool flag = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "BH_sp_DonDatHangChiTietDieuKhoan", commandParameters) > 0;
                flag2 = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag2 = false;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public bool SaveHoaDonDieuKhoan()
        {
            bool flag2;
            IDataParameter[] commandParameters = new IDataParameter[7];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaBaoGia", DbType.Int64, ParameterDirection.Input, this.mKhoaChungTu);
                commandParameters[2] = DBHelper.createParameter("@KhoaDieuKhoan", DbType.Int64, ParameterDirection.Input, this.mKhoaDieuKhoan);
                commandParameters[3] = DBHelper.createParameter("@NoiDungViet", DbType.Int64, ParameterDirection.Input, this.mNoiDungViet);
                commandParameters[4] = DBHelper.createParameter("@NoiDungAnh", DbType.Int64, ParameterDirection.Input, this.mNoiDungAnh);
                commandParameters[5] = DBHelper.createParameter("@HienThi", DbType.Double, ParameterDirection.Input, this.mHienThi);
                commandParameters[6] = DBHelper.createParameter("@STT", DbType.Double, ParameterDirection.Input, this.mSTT);
                bool flag = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "BH_sp_XuatBanChiTietDieuKhoan", commandParameters) > 0;
                flag2 = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag2 = false;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public bool SaveYeuCauBaoGiaDieuKhoan()
        {
            bool flag2;
            IDataParameter[] commandParameters = new IDataParameter[7];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaYeuCauBaoGia", DbType.Int64, ParameterDirection.Input, this.mKhoaChungTu);
                commandParameters[2] = DBHelper.createParameter("@KhoaDieuKhoan", DbType.Int64, ParameterDirection.Input, this.mKhoaDieuKhoan);
                commandParameters[3] = DBHelper.createParameter("@NoiDung", DbType.Int64, ParameterDirection.Input, this.mNoiDungViet);
                commandParameters[4] = DBHelper.createParameter("@NoiDungAnh", DbType.Int64, ParameterDirection.Input, this.mNoiDungAnh);
                commandParameters[5] = DBHelper.createParameter("@HienThi", DbType.Double, ParameterDirection.Input, this.mHienThi);
                commandParameters[6] = DBHelper.createParameter("@STT", DbType.Double, ParameterDirection.Input, this.mSTT);
                bool flag = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "MH_sp_YeuCauBaoGiaDieuKhoan", commandParameters) > 0;
                flag2 = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag2 = false;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public int HienThi
        {
            get
            {
                return this.mHienThi;
            }
            set
            {
                this.mHienThi = value;
            }
        }

        public string Khoa
        {
            get
            {
                return this.mKhoa;
            }
            set
            {
                this.mKhoa = value;
            }
        }

        public string KhoaChungTu
        {
            get
            {
                return this.mKhoaChungTu;
            }
            set
            {
                this.mKhoaChungTu = value;
            }
        }

        public string KhoaDieuKhoan
        {
            get
            {
                return this.mKhoaDieuKhoan;
            }
            set
            {
                this.mKhoaDieuKhoan = value;
            }
        }

        public string LoaiChungTu
        {
            get
            {
                return this.mLoaiChungTu;
            }
            set
            {
                this.mLoaiChungTu = value;
            }
        }

        public string NoiDungAnh
        {
            get
            {
                return this.mNoiDungAnh;
            }
            set
            {
                this.mNoiDungAnh = value;
            }
        }

        public string NoiDungViet
        {
            get
            {
                return this.mNoiDungViet;
            }
            set
            {
                this.mNoiDungViet = value;
            }
        }

        public int STT
        {
            get
            {
                return this.mSTT;
            }
            set
            {
                this.mSTT = value;
            }
        }
    }
}

